package org.ricks.common.conf;


/**
 * @author chenwei
 * @Title:
 * @Package
 * @Description:
 * @date 2020/12/1720:07
 */
@ConfProperties(prefix = "jdbc.")
public class JdbcConfig {

    private static String driverClassName = "com.mysql.cj.jdbc.Driver";

    private static int poolMaximumActiveConnections = 20;//最大活跃链接

    private static int poolMaximumIdleConnections = 10;//最大空闲链接

    /** 默认主库 */
    private static String url = "jdbc:mysql://192.168.18.25:3306/ricks?characterEncoding=utf8&serverTimezone=UTC&rewriteBatchedStatements=true&useSSL=true&autoReconnect=true&failOverReadOnly=false";
    private static String username = "root";
    private static String password = "123456";
    /** 从库 */
    private static String slaveUrl = "";
    private static String slaveUsername = "";
    private static String slavePassword = "";

    /**
     * 解决mysql空闲连接断开8小时魔咒
     * 默认开启 ping
     */
    private static boolean poolPingEnabled = true;

    private static String poolPingQuery = "SELECT 1";

    private static int poolPingConnectionsNotUsedFor = 3600000;

    public static String getDriverClassName() {
        return driverClassName;
    }

    public static String getUrl() {
        return url;
    }

    public static String getUsername() {
        return username;
    }

    public static String getPassword() {
        return password;
    }

    public static void setDriverClassName(String driverClassName) {
        JdbcConfig.driverClassName = driverClassName;
    }

    public static void setUrl(String url) {
        JdbcConfig.url = url;
    }

    public static void setUsername(String username) {
        JdbcConfig.username = username;
    }

    public static void setPassword(String password) {
        JdbcConfig.password = password;
    }

    public static boolean isPoolPingEnabled() {
        return poolPingEnabled;
    }

    public static void setPoolPingEnabled(boolean poolPingEnabled) {
        JdbcConfig.poolPingEnabled = poolPingEnabled;
    }

    public static String getPoolPingQuery() {
        return poolPingQuery;
    }

    public static void setPoolPingQuery(String poolPingQuery) {
        JdbcConfig.poolPingQuery = poolPingQuery;
    }

    public static int getPoolPingConnectionsNotUsedFor() {
        return poolPingConnectionsNotUsedFor;
    }

    public static void setPoolPingConnectionsNotUsedFor(int poolPingConnectionsNotUsedFor) {
        JdbcConfig.poolPingConnectionsNotUsedFor = poolPingConnectionsNotUsedFor;
    }

    public static int getPoolMaximumActiveConnections() {
        return poolMaximumActiveConnections;
    }

    public static void setPoolMaximumActiveConnections(int poolMaximumActiveConnections) {
        JdbcConfig.poolMaximumActiveConnections = poolMaximumActiveConnections;
    }

    public static int getPoolMaximumIdleConnections() {
        return poolMaximumIdleConnections;
    }

    public static void setPoolMaximumIdleConnections(int poolMaximumIdleConnections) {
        JdbcConfig.poolMaximumIdleConnections = poolMaximumIdleConnections;
    }

    public static String getSlaveUrl() {
        return slaveUrl;
    }

    public static void setSlaveUrl(String slaveUrl) {
        JdbcConfig.slaveUrl = slaveUrl;
    }

    public static String getSlaveUsername() {
        return slaveUsername;
    }

    public static void setSlaveUsername(String slaveUsername) {
        JdbcConfig.slaveUsername = slaveUsername;
    }

    public static String getSlavePassword() {
        return slavePassword;
    }

    public static void setSlavePassword(String slavePassword) {
        JdbcConfig.slavePassword = slavePassword;
    }
}
